<template>
  <el-dialog title="选择车辆" :visible.sync="dialogBoole" width="1200px">
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-form-item label="订单编号:">
        <el-input v-model="form.orderNo" clearable placeholder="请输入车牌号"/>
      </el-form-item>
      <el-form-item label="出租方:">
        <el-input v-model="customerName" @focus="handleFocus" ref="refInput" clearable
                  placeholder="请输入出租方"/>
      </el-form-item>
      <el-form-item label="承租方:">
        <el-select v-model="form.leaseeId" placeholder="请选择工单状态">
          <el-option v-for="item in rentOutList" :label="item.deptName"
                     :value="item.deptId" :key="item.deptId"/>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button @click="resetQuery">重置</el-button>
        <el-button type="primary" @click.stop="handleQuery">查询</el-button>
      </el-form-item>

    </el-form>

    <table-page :dataList="tableData" border :total="total" :page.sync="form.pageNum"
                :limit.sync="form.pageSize" @setSizeCurrent="handleList">
      <template slot="tableColAc">
        <el-table-column label="操作" align="center" fixed="left" width="100">
          <template #default="{row}">
            <el-button size="mini" type="text" @click="handleSelect(row)">
              选择车辆
            </el-button>
          </template>
        </el-table-column>
      </template>

      <template slot="tableCol">
        <el-table-column label="订单编号" prop="orderNo" show-overflow-tooltip align="center"/>

        <el-table-column label="订单状态" prop="orderStatus" show-overflow-tooltip align="center">
          <template #default="{row}">
            {{ selectDictLabel(dict.type.order_status, row.orderStatus) || '-' }}
          </template>
        </el-table-column>

        <el-table-column label="出租方" prop="lessorName" show-overflow-tooltip align="center"/>

        <el-table-column label="承租方" prop="leaseeName" show-overflow-tooltip align="center"/>

        <el-table-column label="交车总数量" prop="quantityDelivery" show-overflow-tooltip align="center"/>

        <el-table-column label="已交车数量" prop="quantityDelivered" show-overflow-tooltip align="center"/>

        <el-table-column label="未交车数量" prop="quantityUndelivered" show-overflow-tooltip align="center"/>

      </template>
    </table-page>
  </el-dialog>
</template>

<script>
import * as apis from "@/api/deliveryVehicle"

export default {
  name: 'addDialog',
  dicts:['order_status'],
  props: {
    rentOutList: {
      type: Array,
      default: []
    }
  },
  computed: {},
  watch: {},
  data() {
    return {
      form: {
        orderNo: '',
        lessorId: '',
        leaseeId: '',
        pageSize: 10,
        pageNum: 1,
      },
      customerName: '',
      total: 0,
      dialogBoole: false,
      tableData: [{carNo: '豫C213R91'}],
    };
  },
  created() {
  },
  mounted() {
  },
  methods: {
    handleFocus() {
      this.$SelectDialog({title: '', type: 'userNo'}).then(
          ({res, type}) => {
            this.form.lessorId = res.customerId
            this.customerName = res.customerName
            this.$refs.refInput.blur()
          },
      );
    },

    handleSelect(row) {
      this.dialogBoole = false
      this._toPage({
        path: "/vehicleOrder/orderManagement/DeliveryVehicleEdit",
        name: 'DeliveryVehicleEdit',
        query:{
          id:row.orderId
        }
      });
    },

    handleOpen() {
      this.dialogBoole = true
      this.handleList()
    },

    resetQuery() {
      this.form = {
        orderNo: '',
        lessorId: '',
        leaseeId: '',
        pageSize: 10,
        pageNum: 1,
      }
      this.customerName = ''
      this.handleList()
    },

    handleQuery() {
      this.form.pageNum = 1
      this.handleList()
    },

    async handleList() {
      try {
        const res = await apis?.queryOrderPageList(this.form)
        this.tableData = res.rows
        this.total = res.total
      } catch (e) {
        console.error(e)
      }

    }
  },
};
</script>

<style scoped lang=""></style>


